package com.androidx.p013lv.base;

import android.app.Application;
import android.webkit.WebSettings;
import com.androidx.p013lv.base.utils.BuildConfigUtils;
import com.androidx.p013lv.base.utils.CrashHandler;
import com.androidx.p013lv.base.utils.PackageUtils;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.cache.CacheMode;
import com.lzy.okgo.interceptor.HttpLoggingInterceptor;
import com.lzy.okgo.model.HttpHeaders;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import okhttp3.OkHttpClient;

/* renamed from: com.androidx.lv.base.BaseSdk */
public class BaseSdk {
    public static String UserAgent;
    private static Application mContext;
    public static OkHttpClient okHttpClient;

    public static void init(Application application) {
        mContext = application;
        CrashHandler.getInstance().init();
        initOkgo();
        UserAgent = WebSettings.getDefaultUserAgent(mContext) + ";SuiRui/k/ver=" + PackageUtils.getVersionName(mContext);
    }

    private static void initOkgo() {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        builder.readTimeout(10, TimeUnit.SECONDS);
        builder.writeTimeout(10, TimeUnit.SECONDS);
        builder.connectTimeout(10, TimeUnit.SECONDS);
        if (BuildConfigUtils.isIsDebug()) {
            HttpLoggingInterceptor httpLoggingInterceptor = new HttpLoggingInterceptor("--okgo");
            httpLoggingInterceptor.setPrintLevel(HttpLoggingInterceptor.Level.BODY);
            httpLoggingInterceptor.setColorLevel(Level.INFO);
            builder.addInterceptor(httpLoggingInterceptor);
        }
        HttpHeaders httpHeaders = new HttpHeaders();
        okHttpClient = builder.build();
        OkGo.getInstance().init(getContext()).setOkHttpClient(okHttpClient).setCacheMode(CacheMode.NO_CACHE).setCacheTime(-1).setRetryCount(0).addCommonHeaders(httpHeaders);
    }

    public static OkHttpClient getOkHttpClient() {
        if (okHttpClient == null) {
            initOkgo();
        }
        return okHttpClient;
    }

    public static Application getContext() {
        return mContext;
    }
}
